翻訳と辞書 |
referential transparency : FOLDOC | referential transparency An expression E is referentially transparent if any subexpression and its value (the result of evaluating it) can be interchanged without changing the value of E. This is not the case if the value of an expression depends on global state which can change value. The most common example of changing global state is assignment to a global variable. For example, if y is a global variable in: f(x) { return x+y; }
g(z) { a = f(1); y = y + z; return a + f(1); }
function g has the "side-effect" that it alters the value of y. Since f's result depends on y, the two calls to f(1) will return different results even though the argument is the same. Thus f is not referentially transparent. Changing the order of evaluation of the statements in g will change its result. {Pure functional languages} achieve referential transparency by forbidding assignment to global variables. Each expression is a c
スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース |
Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.
|
|